<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加</title>
    <script src="js/jquery-1.10.2.js"></script>
    <script>
        $(function () {
            $("#myAdd").submit(function () {
                var bookName = $("input[name='bookName']").val();
                var bookAuthor = $("input[name='bookAuthor']").val();

                if (bookName == "") {
                    alert("名字不能为空");
                    return false;
                } else if (bookAuthor == "") {
                    alert("作者不能为空");
                    return false;
                }
            });
        })
    </script>
</head>
<body>
<form action="add" method="post" id="myAdd">
    <table style="margin: 0px auto;width: 400px;">
        <tr>
            <th colspan="2" align="center"><h3>添加图书</h3></th>
        </tr>
        <tr>
            <td>书名:</td>
            <td><input type="text" name="bookName"/></td>
        </tr>
        <tr>
            <td>作者:</td>
            <td><input type="text" name="bookAuthor"/></td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <input type="submit" value="提交"/>
                <input type="button" value="返回" onclick="history.back();"/>
            </td>
        </tr>

    </table>

</form>
</body>
</html>

